{% extends "base.html" %}
{% block content %}


{% if rents%}
{% for r in rents%}
<div class="house-title">
    <h1 class="c_333 f20">{{r.title}}</h1>
    <p class="c_888 f12">{{r.date}}发布&nbsp;&nbsp;&nbsp;{{r.times}}人浏览</p>
    <div class="title-right-info">
        {% if current_user.role_id == 1 or current_user.id == r.author_id %}
        <a class="btn btn-app" href="/bd/view_rent?id={{r.id}}"><i class="fa fa-edit"></i> 编辑</a>
        <a class="btn btn-app" id="delete" value="{{r.id}}"><i class="fa fa-trash-o"></i> 删除</a>
        {%else%}
        {% if like==False%}
        <a class="btn btn-app"id="like" value="{{r.id}}">
            <i class="fa fa-heart-o"></i> 收藏
        </a>
        {%else%}
        <a class="btn btn-app" id="unlike" value="{{r.id}}">
            <i class="fa fa-heart"></i> 取消收藏 
        </a>
        {% endif %}
        {% endif %}
    </div>

</div>
<table>
    <tr>
        <td rowspan="7">
            {% if r.rentimages and r.rentimages|length >1%}
            <div class="banner" id="b04">
                <ul>
                    {% for image in r.rentimages%}
                    <li><img src="{{"/bd/web/static/"+image.file}}" width="640" height="400" ></li>
                    {% endfor%}
                    <a href="javascript:void(0);" class="unslider-arrow04 prev"><img class="arrow" id="al" src="/bd/web/static/arrowl.png" alt="prev" width="20" height="35"></a>
                    <a href="javascript:void(0);" class="unslider-arrow04 next"><img class="arrow" id="ar" src="/bd/web/static/arrowr.png" alt="next" width="20" height="37"></a>

                </ul>
            </div>
            {% else%}
            <div>
                <ul><img src="{{"/bd/web/static/"+r.rentimages.file}}" width="640" height="400" ></ul>
            </div>
            {% endif %}
        </td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>
                <span class="c_ff552e">
                    <b class="f36">{{r.price}}</b>
                    元/月
                </span>
            &nbsp;&nbsp;{% if r.rent_type==0 %}押一付一{% else %}押一付三{% endif%}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">租赁方式：</span>{{r.mode.name}}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">所在小区：</span>{{r.residential.name}}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">所属区域：</span>{{r.area.name}}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">详细地址：</span>{{r.address}}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">联系人：</span>{{r.contacts}}</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>
            <span class="c_888">联系方式：</span>{{r.phone_number}}</td>
    </tr>
</table>
<div class="house-fraud-tip">
    <h3>房源描述：</h3>
    <div>{{r.description}}</div>

</div>
{% endfor %}
{% endif %}
{% endblock %}
{% block script %}
<script>
    $(document).ready(function(e) {
        var unslider04 = $('#b04').unslider({
                    dots: true
                }),
                data04 = unslider04.data('unslider');
        $('.unslider-arrow04').click(function() {
            var fn = this.className.split(' ')[1];
            data04[fn]();
        });
    });
</script>
<script>
    $(function(){
        $("#like").click(function(){
            $.ajax({
                type : "get",
                url : "/view_rent",
                cache:false,
                data : {'like_rent_id':$("#like").attr("value")},
                dataType : "String"
            });
        });
    });
</script>
<script>
    $(function(){
        $("#delete").click(function(){
            $.ajax({
                type : "get",
                url : "/bd/my_rent_publish",
                cache:false,
                data : {'delete_rent_id':$("#delete").attr("value")},
                dataType : "String"
            });
        });
    });
</script>
<script>
    $(function(){
        $("#unlike").click(function(){
            $.ajax({
                type : "get",
                url : "/view_rent",
                cache:false,
                data : {'unlike_rent_id':$("#unlike").attr("value")},
                dataType : "String"
            });
        });
    });
</script>
<script>
    $(function(){
        $("#like").click(function(){
            alert("收藏成功")
        });
    });
</script>

<script>
    $(function(){
        $("#unlike").click(function(){
            alert("取消收藏成功")
        });
    });
</script>
<script>
    $(function(){
        $("#delete").click(function(){
            alert("删除成功")
        });
    });
</script>
<script>
    $('#like').click(function() {
        window.location.reload()
    });
</script>
<script>
    $('#unlike').click(function() {
        window.location.reload()
    });
</script>
<script>
    $('#delete').click(function() {
        window.location.href = 'http://127.0.0.1:5000/bd/my_rent_publish';
    });
</script>
{% endblock %}
